package Visitor;

import operatori.*;
import arbori.ArboreFunctional;
import arbori.Nod;
import functii.Constanta;
import functii.Necunoscuta;
import functii.*;

public class ToStringVisitor extends Visitor {
	String sir;

	public void visit(Plus p) {
		if (p.getNs() != null && p.getNd() != null) {
			visit(p.getNs());
			String s1 = this.sir;
			visit(p.getNd());
			String s2 = this.sir;
			sir = p.concatTermeni(s1, s2);
		}

	}

	public void visitare(Operator o) {

	}

	public void visitare(Functie f) {

	}

	public void visit(Minus m) {
		if (m.getNs() != null && m.getNd() != null) {
			visit(m.getNs());
			String s1 = this.sir;
			visit(m.getNd());
			String s2 = this.sir;
			sir = m.concatTermeni(s1, s2);
		}
	}

	public void visit(Cat c) {
		if (c.getNs() != null && c.getNd() != null) {
			visit(c.getNs());
			String s1 = this.sir;
			visit(c.getNd());
			String s2 = this.sir;
			sir = c.concatTermeni(s1, s2);
		}
	}

	public void visit(Produs p) {
		if (p.getNs() != null && p.getNd() != null) {
			visit(p.getNs());
			String s1 = this.sir;
			visit(p.getNd());
			String s2 = this.sir;
			sir = p.concatTermeni(s1, s2);
		}
	}

	public void visit(Necunoscuta n) {
		this.sir = "x";
	}

	public void visit(Constanta c) {
		this.sir = Double.toString(c.getCt());
	}

	public ToStringVisitor() {
		super();
	}

	public ToStringVisitor(String sir) {
		super();
		this.sir = sir;
	}

	public String getS() {
		return sir;
	}

	public void setS(String sir) {
		this.sir = sir;
	}

	public void visit(Sin s) {
		if (s.getNs() != null) {
			visit(s.getNs());
			String s1 = this.sir;
			sir = s.concatTermeni(s1);
		}
	}

	public void visit(Cos c) {

	}

	public void visit(Nod n) {

	}

	public void visit(ArboreFunctional a) {

	}

}
